package com.sto.stoapp.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.sto.stoapp.activity.R;
import com.sto.stoapp.entity.FlightCompareEntity;

/**
 * 航班对比查询
 * @author mgf
 *
 */
public class InquiryFlightComAdapter extends BaseAdapter {
    
    private List<FlightCompareEntity> courierList;

    private Context context;

    /**
     * 构造函数
     * 
     * @param context
     * @param courierList
     */
    public InquiryFlightComAdapter(Context context, List<FlightCompareEntity> list) {
        this.courierList = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        return courierList == null ? 0 : courierList.size();
    }

    @Override
    public Object getItem(int arg0) {
        return courierList.get(arg0);
    }

    @Override
    public long getItemId(int arg0) {
        return arg0;
    }

    @Override
    public View getView(int position, View view, ViewGroup parent) {
        Holder holder;
        if (view == null) {
            holder = new Holder();
            view = LayoutInflater.from(context).inflate(
                    R.layout.sto_inquiry_flight_compare, null);
            holder.flight = (TextView) view
                    .findViewById(R.id.inquiry_compare_flight);
            holder.need = (TextView) view
                    .findViewById(R.id.inquiry_compare_need);
            holder.reality = (TextView) view
                    .findViewById(R.id.inquiry_compare_realy);
            view.setTag(holder);
        } else {
            holder = (Holder) view.getTag();
        }
        holder.flight.setText("航班:" + courierList.get(position).getFlight());
        holder.need.setText("应到:" + courierList.get(position).getNeedCount());
        holder.reality.setText("实到:" + courierList.get(position).getRealityCount());
        return view;
    }

    class Holder {
        TextView flight;
        TextView need;
        TextView reality;
        
    }

}
